#include "EditorGUI.hpp"

EditorGUI::EditorGUI(EditorManager* pEditorManager)
{
	m_pEditorManager = pEditorManager;

	// Create the GUI
	Lua->RunScript("Scripts\\UI\\DisableAll.lua");
	//GUI->RegisterPanel(Key->GetPanelIDs()->Editor_Algorithms);
	//GUI->ActivatePanel();
	GUI->RegisterPanel(Key->GetPanelIDs()->Editor_Buttons);
	GUI->ActivatePanel();
	//GUI->RegisterPanel(Key->GetPanelIDs()->Editor_Tiles);
	//GUI->ActivatePanel();

}

void EditorGUI::HandleEvents(SDL_Event* event)
{
	
}

void EditorGUI::Render()
{
	GUI->Render();

	OGL_Color col = Key->GetColor("100, 080, 080, 180");
	int x1 = 10, y1 = 10, x2 = 160, y2 = 25, increment = 15;
	int fx = 15, fy = 13; fy -= increment;
	string str;

	// addition template
	// if(you want it when selecting or not)
	// {
	//	Draw the rectangle and increment values
	//	str = "Intro: "
	//	str += value
	//	Render at fx, fy, with specified color
	// }

	// Render room layer
	if(!m_pEditorManager->m_DrawSelectionBox)
	{
		// render our rectangle and increment the variables
		DrawPrimitives->DrawRectangle(x1, y1, x2, y2, col);	y1 += increment;	y2 += increment;	fy += increment;
		str = "Room layer: ";
		str += GetString(m_pEditorManager->m_RoomSelectionStart);
		Key->GetFont("onuava small")->drawText(fx, fy, str, orange);
	}
	
	// Render Density
	if(m_pEditorManager->m_DrawSelectionBox)
	{
		DrawPrimitives->DrawRectangle(x1, y1, x2, y2, col);	y1 += increment;	y2 += increment;	fy += increment;
		str = "Density: ";
		str += GetString(m_pEditorManager->m_Density);
		Key->GetFont("onuava small")->drawText(fx, fy, str, orange);
	}

	// Render Path Width
	if(!m_pEditorManager->m_DrawSelectionBox)
	{
		DrawPrimitives->DrawRectangle(x1, y1, x2, y2, col);	y1 += increment;	y2 += increment;	fy += increment;
		str = "Path Width: ";
		str += GetString(m_pEditorManager->m_PathWidth);
		Key->GetFont("onuava small")->drawText(fx, fy, str, orange);
	}

	// Render Smooth Path
	if(!m_pEditorManager->m_DrawSelectionBox)
	{
		DrawPrimitives->DrawRectangle(x1, y1, x2, y2, col);	y1 += increment;	y2 += increment;	fy += increment;
		str = "Smooth Path: ";
		str += GetString(m_pEditorManager->m_SmoothPath);
		Key->GetFont("onuava small")->drawText(fx, fy, str, orange);
	}

	// Render Is River
	if(!m_pEditorManager->m_DrawSelectionBox)
	{
		DrawPrimitives->DrawRectangle(x1, y1, x2, y2, col);	y1 += increment;	y2 += increment;	fy += increment;
		str = "Is River: ";
		if(m_pEditorManager->m_PathRiver == false)
			str += "false";
		else
			str += "true";
		Key->GetFont("onuava small")->drawText(fx, fy, str, orange);
	}

	// Coordinates of Selection box
	if(m_pEditorManager->m_DrawSelectionBox)
	{
		
		DrawPrimitives->DrawRectangle(x1, y1, x2, y2, col); y1 += increment;	y2 += increment;	fy += increment;
		Key->GetFont("onuava small")->drawText(fx, fy, m_pEditorManager->m_pSelectionBoxHandler->GetLocation("max x1y1").String(), red);//, "max x2y2", "min x1y1", "min x2y2");
		
		DrawPrimitives->DrawRectangle(x1, y1, x2, y2, col); y1 += increment;	y2 += increment;	fy += increment;
		Key->GetFont("onuava small")->drawText(fx, fy, m_pEditorManager->m_pSelectionBoxHandler->GetLocation("max x2y2").String(), red);
		
		DrawPrimitives->DrawRectangle(x1, y1, x2, y2, col); y1 += increment;	y2 += increment;	fy += increment;
		Key->GetFont("onuava small")->drawText(fx, fy, m_pEditorManager->m_pSelectionBoxHandler->GetLocation("min x1y1").String(), blue);//, "max x2y2", "min x1y1", "min x2y2");
		
		DrawPrimitives->DrawRectangle(x1, y1, x2, y2, col); y1 += increment;	y2 += increment;	fy += increment;
		Key->GetFont("onuava small")->drawText(fx, fy, m_pEditorManager->m_pSelectionBoxHandler->GetLocation("min x2y2").String(), blue);
	}

	DrawPrimitives->DrawRectangle(x1, y1, x2, y2 - (increment / 2), col);
	/*int x1 = 10, y1 = 10, x2 = 160;
	DrawPrimitives->DrawRectangle(x1, y1, x2, y1 + 35, Key->GetColor("100, 080, 080, 180"));

	string str = "Room layer: ";
	str += GetString(m_pEditorManager->m_RoomSelectionStart);
	Key->GetFont("onuava small")->drawText(15, 15, str, orange);

	

	if(m_pEditorManager->m_DrawSelectionBox)
	{
		DrawPrimitives->DrawRectangle(x1, y1 + 35, x2, 90, Key->GetColor("100, 080, 080, 180"));
		Key->GetFont("onuava small")->drawText(15, 45, m_pEditorManager->m_pSelectionBoxHandler->GetLocation("max x1y1").String(), red);//, "max x2y2", "min x1y1", "min x2y2");
		Key->GetFont("onuava small")->drawText(15, 55, m_pEditorManager->m_pSelectionBoxHandler->GetLocation("max x2y2").String(), red);
		Key->GetFont("onuava small")->drawText(15, 65, m_pEditorManager->m_pSelectionBoxHandler->GetLocation("min x1y1").String(), blue);//, "max x2y2", "min x1y1", "min x2y2");
		Key->GetFont("onuava small")->drawText(15, 75, m_pEditorManager->m_pSelectionBoxHandler->GetLocation("min x2y2").String(), blue);
	}*/
	
}

void EditorGUI::Update()
{
	GUI->Update();

	
}